package com.xl.singletonPattern;
/**
 * 懒汉式单例模式-线程安全
 */
public class SynchronizedSingleton {
    private static SynchronizedSingleton singleton;
    private SynchronizedSingleton() {
        System.out.println("创建实例...");
    }
    public static synchronized SynchronizedSingleton getInstance() {
        if (singleton == null) {
            singleton = new SynchronizedSingleton();
        }
        return singleton;
    }
}
